import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * crea una coleccion de naves enemigas de tipo Banshee
 * 
 * @author (Octavio y Cesar) 
 * @version (2014.11.28)
 */
public class BansheeGroup extends Actor
{
    private boolean added=false;
    private Banshee[] banshees=new Banshee[4];
    private Timer time;

    /**
     * contructor de variables para la clase BansheeGroup
     */
    public BansheeGroup()
    {
        time= new Timer();
        GreenfootImage image=getImage();
        image.scale(40,40);
        image.setTransparency(0);
        setImage(image);

        for(int i=0;i<banshees.length;i++)
            banshees[i]=new Banshee(100,100,150,Math.PI+i);
    }

    public void act() 
    {  
        time.increases();    
        if(time.getTime()==5)
        {

            if(added==false)
            {
                addBanshees();
                added=true;
            }

            moveBanshees();

            if(getY()<getWorld().getHeight()-200)
                setLocation(getX(),getY()+3);

            if(banshees.length==0)
                getWorld().removeObject(this);

            time.reset();
        }
    }    

    /**
     * agrega a las naves de tipo Banshee al mundo
     */
    public void addBanshees()
    {
        
        for(int i=0;i<banshees.length;i++)
           { 
            getWorld().addObject(banshees[i],getX(),getY());
           }
    }

    /**
     * mueve a los Banshee
     */
    public void moveBanshees()
    {
        
        
        for(int i=0;i<banshees.length;i++)
           { 
            banshees[i].changeCenter(getX(),getY());  
           
            }
    }
}

